package com.grass.p019lv.novel.viewmodel;

import androidx.core.app.NotificationCompat;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.JsonParams;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.utils.JsonUtils;
import com.grass.p019lv.bean.NovelCommentBean;
import com.grass.p019lv.bean.NovelCommentData;
import com.grass.p019lv.bean.NovelReplyBean;
import com.lzy.okgo.model.Response;
import com.yalantis.ucrop.view.CropImageView;

/* renamed from: com.grass.lv.novel.viewmodel.NovelCommentModel */
public class NovelCommentModel extends ViewModel {
    private MutableLiveData<BaseRes<NovelCommentBean>> commentBean;
    private MutableLiveData<BaseRes<NovelCommentData>> commentList;
    private MutableLiveData<BaseRes<NovelReplyBean>> replyBean;

    public MutableLiveData<BaseRes<NovelCommentData>> commentList() {
        if (this.commentList == null) {
            this.commentList = new MutableLiveData<>();
        }
        return this.commentList;
    }

    public MutableLiveData<BaseRes<NovelCommentBean>> addComment() {
        if (this.commentBean == null) {
            this.commentBean = new MutableLiveData<>();
        }
        return this.commentBean;
    }

    public MutableLiveData<BaseRes<NovelReplyBean>> addCommentReply() {
        if (this.replyBean == null) {
            this.replyBean = new MutableLiveData<>();
        }
        return this.replyBean;
    }

    public void loadNovelComment(int i, int i2, String str) {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().novelCommentList(i, i2, str), new HttpCallback<BaseRes<NovelCommentData>>("loadVideoComment") {
            /* class com.grass.p019lv.novel.viewmodel.NovelCommentModel.C32101 */

            public void onLvSuccess(BaseRes<NovelCommentData> baseRes) {
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.Callback
            public void onSuccess(Response<BaseRes<NovelCommentData>> response) {
                NovelCommentModel.this.commentList.setValue(response.body());
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.AbsCallback, com.lzy.okgo.callback.Callback
            public void onError(Response<BaseRes<NovelCommentData>> response) {
                super.onError(response);
                NovelCommentModel.this.commentList.setValue(new BaseRes(CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION, ""));
            }
        });
    }

    public void commitComment(int i, int i2, String str) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().novelComment(), JsonParams.build().add("chapterId", Integer.valueOf(i2)).add("content", str).add("fictionId", Integer.valueOf(i)).commit(), new HttpCallback<BaseRes<NovelCommentBean>>("saveComment") {
            /* class com.grass.p019lv.novel.viewmodel.NovelCommentModel.C32112 */

            public void onLvSuccess(BaseRes<NovelCommentBean> baseRes) {
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.Callback
            public void onSuccess(Response<BaseRes<NovelCommentBean>> response) {
                NovelCommentModel.this.commentBean.setValue(response.body());
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.AbsCallback, com.lzy.okgo.callback.Callback
            public void onError(Response<BaseRes<NovelCommentBean>> response) {
                super.onError(response);
                try {
                    String message = response.getException().getMessage();
                    NovelCommentModel.this.commentBean.setValue(new BaseRes(JsonUtils.getInt("code", message), JsonUtils.getString(NotificationCompat.CATEGORY_MESSAGE, message)));
                } catch (Exception unused) {
                    NovelCommentModel.this.commentBean.setValue(new BaseRes(CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION, ""));
                }
            }
        });
    }

    public void replyComment(NovelCommentBean novelCommentBean, String str) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().novelComment(), JsonParams.build().add("backUserId", Integer.valueOf(novelCommentBean.getUserId())).add("chapterId", Integer.valueOf(novelCommentBean.getChapterId())).add("content", str).add("fictionId", Integer.valueOf(novelCommentBean.getFictionId())).add("parenId", novelCommentBean.getParentId()).commit(), new HttpCallback<BaseRes<NovelReplyBean>>("saveComment") {
            /* class com.grass.p019lv.novel.viewmodel.NovelCommentModel.C32123 */

            public void onLvSuccess(BaseRes<NovelReplyBean> baseRes) {
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.Callback
            public void onSuccess(Response<BaseRes<NovelReplyBean>> response) {
                NovelCommentModel.this.replyBean.setValue(response.body());
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.AbsCallback, com.lzy.okgo.callback.Callback
            public void onError(Response<BaseRes<NovelReplyBean>> response) {
                super.onError(response);
                try {
                    String message = response.getException().getMessage();
                    NovelCommentModel.this.replyBean.setValue(new BaseRes(JsonUtils.getInt("code", message), JsonUtils.getString(NotificationCompat.CATEGORY_MESSAGE, message)));
                } catch (Exception unused) {
                    NovelCommentModel.this.replyBean.setValue(new BaseRes(CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION, ""));
                }
            }
        });
    }

    public void replyOneComment(NovelCommentBean novelCommentBean, String str) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().novelComment(), JsonParams.build().add("chapterId", Integer.valueOf(novelCommentBean.getChapterId())).add("content", str).add("fictionId", Integer.valueOf(novelCommentBean.getFictionId())).add("parenId", novelCommentBean.getId()).commit(), new HttpCallback<BaseRes<NovelReplyBean>>("saveComment") {
            /* class com.grass.p019lv.novel.viewmodel.NovelCommentModel.C32134 */

            public void onLvSuccess(BaseRes<NovelReplyBean> baseRes) {
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.Callback
            public void onSuccess(Response<BaseRes<NovelReplyBean>> response) {
                NovelCommentModel.this.replyBean.setValue(response.body());
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.AbsCallback, com.lzy.okgo.callback.Callback
            public void onError(Response<BaseRes<NovelReplyBean>> response) {
                super.onError(response);
                try {
                    String message = response.getException().getMessage();
                    NovelCommentModel.this.replyBean.setValue(new BaseRes(JsonUtils.getInt("code", message), JsonUtils.getString(NotificationCompat.CATEGORY_MESSAGE, message)));
                } catch (Exception unused) {
                    NovelCommentModel.this.replyBean.setValue(new BaseRes(CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION, ""));
                }
            }
        });
    }

    public void replyTwoComment(NovelReplyBean novelReplyBean, String str) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().novelComment(), JsonParams.build().add("backUserId", Integer.valueOf(novelReplyBean.getUserId())).add("chapterId", Integer.valueOf(novelReplyBean.getChapterId())).add("content", str).add("fictionId", Integer.valueOf(novelReplyBean.getFictionId())).add("parenId", novelReplyBean.getParentId()).commit(), new HttpCallback<BaseRes<NovelReplyBean>>("saveComment") {
            /* class com.grass.p019lv.novel.viewmodel.NovelCommentModel.C32145 */

            public void onLvSuccess(BaseRes<NovelReplyBean> baseRes) {
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.Callback
            public void onSuccess(Response<BaseRes<NovelReplyBean>> response) {
                NovelCommentModel.this.replyBean.setValue(response.body());
            }

            @Override // com.androidx.p013lv.base.http.callback.HttpCallback, com.lzy.okgo.callback.AbsCallback, com.lzy.okgo.callback.Callback
            public void onError(Response<BaseRes<NovelReplyBean>> response) {
                super.onError(response);
                try {
                    String message = response.getException().getMessage();
                    NovelCommentModel.this.replyBean.setValue(new BaseRes(JsonUtils.getInt("code", message), JsonUtils.getString(NotificationCompat.CATEGORY_MESSAGE, message)));
                } catch (Exception unused) {
                    NovelCommentModel.this.replyBean.setValue(new BaseRes(CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION, ""));
                }
            }
        });
    }
}
